<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${name}Mapper">
	<resultMap id="BaseResultMap" type="${name}">
		<#if keyFieldInfos ??>
			<#list keyFieldInfos as key>
			<id column="${key.column}" property="${key.name}" />
			</#list>
		</#if>
		<#if colFieldInfos ??>
			<#list colFieldInfos as col>
			<result column="${col.column}" property="${col.name}" />
			</#list>
		</#if>
	</resultMap>

	<sql id="Base_Column_List">
		<#if keyFieldInfos ??>
			<#list keyFieldInfos as key>
			${key.column}<#if key_has_next>,</#if></#list></#if><#if colFieldInfos ??>,<#list colFieldInfos as col>${col.column}<#if col_has_next>,</#if>
			</#list>
		</#if>
	</sql>

<!---->
	<#if keyFieldInfos ??>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" <#if (keyFieldInfos?size >1) >parameterType="${name}"<#else>parameterType="${keyFieldInfos[0].type}"</#if> >
		select
		<include refid="Base_Column_List" />
		from ${table}
		<where>
			<#list keyFieldInfos as key>
			and ${key.column}=${"#"}{${key.name}}
			</#list>
		</where>
	</select>
	</#if>

	<select id="selectSelective" resultMap="BaseResultMap" parameterType="${name}">
		select
		<include refid="Base_Column_List" />
		from ${table}
		<where>
			<#if keyFieldInfos ??>
				<#list keyFieldInfos as key>
				<if test="${key.name}!= null">and ${key.column}=${"#"}{${key.name}}</if>
				</#list>
			</#if>
			<#if colFieldInfos ??>
				<#list colFieldInfos as col>
				<if test="${col.name}!= null">and ${col.column}=${"#"}{${col.name}}</if>
				</#list>
			</#if>
		</where>
	</select>
	
	<select id="selectSelectiveCount" resultMap="BaseResultMap" parameterType="${name}">
		select count(*) from ${table}
		<where>
			<#if keyFieldInfos ??>
				<#list keyFieldInfos as key>
				<if test="${key.name}!= null">and ${key.column}=${"#"}{${key.name}}</if>
				</#list>
			</#if>
			<#if colFieldInfos ??>
				<#list colFieldInfos as col>
				<if test="${col.name}!= null">and ${col.column}=${"#"}{${col.name}}</if>
				</#list>
			</#if>
		</where>
	</select>
	<!---->
	<delete id="deleteSelective" parameterType="${name}">
		delete from ${table}
		<where>
			<#if keyFieldInfos ??>
				<#list keyFieldInfos as key>
				<if test="${key.name}!= null">and ${key.column}=${"#"}{${key.name}}</if>
				</#list>
			</#if>
			<#if colFieldInfos ??>
				<#list colFieldInfos as col>
				<if test="${col.name}!= null">and ${col.column}=${"#"}{${col.name}}</if>
				</#list>
			</#if>
		</where>
	</delete>
	
	<#if keyFieldInfos ??>
	<delete id="deleteByPrimaryKey" <#if (keyFieldInfos?size >1) >parameterType="${name}"<#else>parameterType="${keyFieldInfos[0].type}"</#if>>
		delete from ${table}
		<where>
			<#list keyFieldInfos as key>
			<if test="${key.name}!= null">and ${key.column}=${"#"}{${key.name}}</if>
			</#list>
		</where>
	</delete>
	</#if>
	
	<insert id="insert" parameterType="${name}">
		insert into
		${table}(
		<include refid="Base_Column_List" />
		)
		values
		(<#if keyFieldInfos ??>
		<#list keyFieldInfos as key>${"#"}{${key.name}}<#if key_has_next>,</#if></#list></#if><#if colFieldInfos ??>,
		<#list colFieldInfos as col>${"#"}{${col.name}}<#if col_has_next>,</#if></#list>
		</#if>)
	</insert>
	
	<#if keyFieldInfos ??>
	<update id="updateByPrimaryKey" parameterType="${name}">
		update ${table} set
		<#list colFieldInfos as col>
		${col.column}=${"#"}{${col.name}}<#if col_has_next>,</#if>
		</#list>
		<where>
			<#list keyFieldInfos as key>
			and ${key.column}=${"#"}{${key.name}}
			</#list>
		</where>
	</update>

	<update id="updateByPrimaryKeySelective" parameterType="${name}">
		update ${table}
		<set>
			<#list colFieldInfos as col>
			<if test="${col.name}!= null"> ${col.column}=${"#"}{${col.name}},</if>
			</#list>
		</set>
		<where>
			<#list keyFieldInfos as key>
			and ${key.column}=${"#"}{${key.name}}
			</#list>
		</where>
	</update>
	</#if>
</mapper>